package cn.tedu.blogger.controller;

import cn.tedu.blogger.entity.User;
import cn.tedu.blogger.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper mapper;

    @RequestMapping("/user/reg")
    public int reg(@RequestBody User user){
        System.out.println("user = " + user);
        user.setCreated(new Date());
            mapper.insert(user);
            return 1;

    }

    @RequestMapping("/login")
    public int login(User user){
        System.out.println("user = " + user);
        user.setCreated(new Date());
        mapper.insert(user);
        return 1;

    }
}
